// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.randomizedWorld.randomizedBuilding;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import zombie.core.Rand;
import zombie.inventory.InventoryItem;
import zombie.inventory.ItemContainer;
import zombie.inventory.ItemPickerJava;
import zombie.iso.BuildingDef;
import zombie.iso.IsoCell;
import zombie.iso.IsoDirections;
import zombie.iso.IsoGridSquare;
import zombie.iso.IsoObject;
import zombie.iso.IsoWorld;
import zombie.iso.objects.IsoCurtain;
import zombie.iso.objects.IsoDoor;
import zombie.iso.objects.IsoRadio;
import zombie.iso.objects.IsoStove;
import zombie.iso.objects.IsoTelevision;
import zombie.iso.objects.IsoThumpable;
import zombie.iso.objects.IsoWindow;
import zombie.iso.sprite.IsoSprite;
import zombie.network.GameServer;
import zombie.randomizedWorld.randomizedBuilding.TableStories.RBTableStoryBase;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSBandPractice;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSBathroomZed;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSBedroomZed;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSBleach;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSCorpsePsycho;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSDeadDrunk;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSFootballNight;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSGunmanInBathroom;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSGunslinger;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSHenDo;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSHockeyPsycho;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSHouseParty;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSPokerNight;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSPoliceAtHouse;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSPrisonEscape;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSPrisonEscapeWithPolice;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSSkeletonPsycho;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSSpecificProfession;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSStagDo;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSStudentNight;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSSuicidePact;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSTinFoilHat;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSZombieLockedBathroom;
import zombie.randomizedWorld.randomizedDeadSurvivor.RDSZombiesEating;
import zombie.randomizedWorld.randomizedDeadSurvivor.RandomizedDeadSurvivorBase;

public final class RBBasic extends RandomizedBuildingBase {
    private final ArrayList<String> specificProfessionDistribution = new ArrayList();
    private final Map<String, String> specificProfessionRoomDistribution = new HashMap();
    private static final HashMap<Integer, String> kitchenSinkItems = new HashMap();
    private static final HashMap<Integer, String> kitchenCounterItems = new HashMap();
    private static final HashMap<Integer, String> kitchenStoveItems = new HashMap();
    private static final HashMap<Integer, String> bathroomSinkItems = new HashMap();
    private final ArrayList<String> coldFood = new ArrayList();
    private final Map<String, String> plankStash = new HashMap();
    private final ArrayList<RandomizedDeadSurvivorBase> deadSurvivorsStory = new ArrayList();
    private int totalChanceRDS = 0;
    private static final HashMap<RandomizedDeadSurvivorBase, Integer> rdsMap = new HashMap();
    private static final ArrayList<String> uniqueRDSSpawned = new ArrayList();
    private ArrayList<IsoObject> tablesDone = new ArrayList();
    private boolean doneTable = false;

    @Override
    public void randomizeBuilding(BuildingDef def) {
        this.tablesDone = new ArrayList();
        boolean boolean0 = Rand.Next(100) <= 20;
        ArrayList arrayList = new ArrayList();
        String string = (String)this.specificProfessionDistribution.get(Rand.Next(0, this.specificProfessionDistribution.size()));
        ItemPickerJava.ItemPickerRoom itemPickerRoom = ItemPickerJava.rooms.get(string);
        IsoCell isoCell = IsoWorld.instance.CurrentCell;
        boolean boolean1 = Rand.NextBool(9);

        for (int int0 = def.x - 1; int0 < def.x2 + 1; int0++) {
            for (int int1 = def.y - 1; int1 < def.y2 + 1; int1++) {
                for (int int2 = 0; int2 < 8; int2++) {
                    IsoGridSquare isoGridSquare = isoCell.getGridSquare(int0, int1, int2);
                    if (isoGridSquare != null) {
                        if (boolean1 && isoGridSquare.getFloor() != null && this.plankStash.containsKey(isoGridSquare.getFloor().getSprite().getName())) {
                            IsoThumpable isoThumpable = new IsoThumpable(
                                isoGridSquare.getCell(),
                                isoGridSquare,
                                (String)this.plankStash.get(isoGridSquare.getFloor().getSprite().getName()),
                                false,
                                null
                            );
                            isoThumpable.setIsThumpable(false);
                            isoThumpable.container = new ItemContainer("plankstash", isoGridSquare, isoThumpable);
                            isoGridSquare.AddSpecialObject(isoThumpable);
                            isoGridSquare.RecalcAllWithNeighbours(true);
                            boolean1 = false;
                        }

                        for (int int3 = 0; int3 < isoGridSquare.getObjects().size(); int3++) {
                            IsoObject isoObject = isoGridSquare.getObjects().get(int3);
                            if (Rand.Next(100) <= 65 && isoObject instanceof IsoDoor && !((IsoDoor)isoObject).isExteriorDoor(null)) {
                                ((IsoDoor)isoObject).ToggleDoorSilent();
                                ((IsoDoor)isoObject).syncIsoObject(true, (byte)1, null, null);
                            }

                            if (isoObject instanceof IsoWindow isoWindow) {
                                if (Rand.NextBool(80)) {
                                    def.bAlarmed = false;
                                    isoWindow.ToggleWindow(null);
                                }

                                IsoCurtain isoCurtain = isoWindow.HasCurtains();
                                if (isoCurtain != null && Rand.NextBool(15)) {
                                    isoCurtain.ToggleDoorSilent();
                                }
                            }

                            if (boolean0
                                && Rand.Next(100) <= 70
                                && isoObject.getContainer() != null
                                && isoGridSquare.getRoom() != null
                                && isoGridSquare.getRoom().getName() != null
                                && ((String)this.specificProfessionRoomDistribution.get(string)).contains(isoGridSquare.getRoom().getName())
                                && itemPickerRoom.Containers.containsKey(isoObject.getContainer().getType())) {
                                isoObject.getContainer().clear();
                                arrayList.add(isoObject.getContainer());
                                isoObject.getContainer().setExplored(true);
                            }

                            if (Rand.Next(100) < 15 && isoObject.getContainer() != null && isoObject.getContainer().getType().equals("stove")) {
                                InventoryItem inventoryItem = isoObject.getContainer().AddItem((String)this.coldFood.get(Rand.Next(0, this.coldFood.size())));
                                inventoryItem.setCooked(true);
                                inventoryItem.setAutoAge();
                            }

                            if (!this.tablesDone.contains(isoObject)
                                && isoObject.getProperties().isTable()
                                && isoObject.getContainer() == null
                                && !this.doneTable) {
                                this.checkForTableSpawn(def, isoObject);
                            }
                        }

                        if (isoGridSquare.getRoom() != null && "kitchen".equals(isoGridSquare.getRoom().getName())) {
                            this.doKitchenStuff(isoGridSquare);
                        }

                        if (isoGridSquare.getRoom() != null && "bathroom".equals(isoGridSquare.getRoom().getName())) {
                            this.doBathroomStuff(isoGridSquare);
                        }

                        if (isoGridSquare.getRoom() != null && "bedroom".equals(isoGridSquare.getRoom().getName())) {
                            this.doBedroomStuff(isoGridSquare);
                        }

                        if (isoGridSquare.getRoom() != null && "livingroom".equals(isoGridSquare.getRoom().getName())) {
                            this.doLivingRoomStuff(isoGridSquare);
                        }
                    }
                }
            }
        }

        for (int int4 = 0; int4 < arrayList.size(); int4++) {
            ItemContainer itemContainer = (ItemContainer)arrayList.get(int4);
            ItemPickerJava.fillContainerType(itemPickerRoom, itemContainer, "", null);
            ItemPickerJava.updateOverlaySprite(itemContainer.getParent());
            if (GameServer.bServer) {
                GameServer.sendItemsInContainer(itemContainer.getParent(), itemContainer);
            }
        }

        if (!boolean0 && Rand.Next(100) < 25) {
            this.addRandomDeadSurvivorStory(def);
            def.setAllExplored(true);
            def.bAlarmed = false;
        }

        this.doneTable = false;
    }

    private void doLivingRoomStuff(IsoGridSquare isoGridSquare) {
        IsoObject isoObject0 = null;
        boolean _boolean = false;

        for (int int0 = 0; int0 < isoGridSquare.getObjects().size(); int0++) {
            IsoObject isoObject1 = isoGridSquare.getObjects().get(int0);
            if (Rand.NextBool(5)
                && isoObject1.getProperties().Val("BedType") == null
                && isoObject1.getSurfaceOffsetNoTable() > 0.0F
                && isoObject1.getSurfaceOffsetNoTable() < 30.0F
                && !(isoObject1 instanceof IsoRadio)) {
                isoObject0 = isoObject1;
            }

            if (isoObject1 instanceof IsoRadio || isoObject1 instanceof IsoTelevision) {
                _boolean = true;
                break;
            }
        }

        if (!_boolean && isoObject0 != null) {
            int int1 = Rand.Next(0, 6);
            String string = "Base.TVRemote";
            switch (int1) {
                case 0:
                    string = "Base.TVRemote";
                    break;
                case 1:
                    string = "Base.TVMagazine";
                    break;
                case 2:
                    string = "Base.Newspaper";
                    break;
                case 3:
                    string = "Base.VideoGame";
                    break;
                case 4:
                    string = "Base.Mugl";
                    break;
                case 5:
                    string = "Base.Headphones";
            }

            IsoDirections isoDirections = this.getFacing(isoObject0.getSprite());
            if (isoDirections != null) {
                if (isoDirections == IsoDirections.E) {
                    this.addWorldItem(string, isoGridSquare, 0.4F, Rand.Next(0.34F, 0.74F), isoObject0.getSurfaceOffsetNoTable() / 96.0F);
                }

                if (isoDirections == IsoDirections.W) {
                    this.addWorldItem(string, isoGridSquare, 0.64F, Rand.Next(0.34F, 0.74F), isoObject0.getSurfaceOffsetNoTable() / 96.0F);
                }

                if (isoDirections == IsoDirections.N) {
                    this.addWorldItem(string, isoGridSquare, Rand.Next(0.44F, 0.64F), 0.67F, isoObject0.getSurfaceOffsetNoTable() / 96.0F);
                }

                if (isoDirections == IsoDirections.S) {
                    this.addWorldItem(string, isoGridSquare, Rand.Next(0.44F, 0.64F), 0.42F, isoObject0.getSurfaceOffsetNoTable() / 96.0F);
                }
            }
        }
    }

    private void doBedroomStuff(IsoGridSquare isoGridSquare) {
        for (int int0 = 0; int0 < isoGridSquare.getObjects().size(); int0++) {
            IsoObject isoObject = isoGridSquare.getObjects().get(int0);
            if (isoObject.getSprite() == null || isoObject.getSprite().getName() == null) {
                return;
            }

            if (Rand.NextBool(7) && isoObject.getSprite().getName().contains("bedding") && isoObject.getProperties().Val("BedType") != null) {
                int int1 = Rand.Next(0, 14);
                switch (int1) {
                    case 0:
                        this.addWorldItem("Shirt_FormalTINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 1:
                        this.addWorldItem("Shirt_FormalWhite_ShortSleeveTINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 2:
                        this.addWorldItem("Tshirt_DefaultDECAL_TINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 3:
                        this.addWorldItem("Tshirt_PoloStripedTINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 4:
                        this.addWorldItem("Tshirt_PoloTINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 5:
                        this.addWorldItem("Jacket_WhiteTINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 6:
                        this.addWorldItem("Jumper_DiamondPatternTINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 7:
                        this.addWorldItem("Jumper_TankTopDiamondTINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 8:
                        this.addWorldItem("HoodieDOWN_WhiteTINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 9:
                        this.addWorldItem("Trousers_DefaultTEXTURE_TINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 10:
                        this.addWorldItem("Trousers_WhiteTINT", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 11:
                        this.addWorldItem("Trousers_Denim", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 12:
                        this.addWorldItem("Trousers_Padded", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 13:
                        this.addWorldItem("TrousersMesh_DenimLight", isoGridSquare, 0.6F, 0.6F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                }
            }

            if (Rand.NextBool(7) && isoObject.getContainer() != null && "sidetable".equals(isoObject.getContainer().getType())) {
                int int2 = Rand.Next(0, 4);
                String string = "Base.Book";
                switch (int2) {
                    case 0:
                        string = "Base.Book";
                        break;
                    case 1:
                        string = "Base.Notebook";
                        break;
                    case 2:
                        string = "Base.VideoGame";
                        break;
                    case 3:
                        string = "Base.CDPlayer";
                }

                IsoDirections isoDirections = this.getFacing(isoObject.getSprite());
                if (isoDirections != null) {
                    if (isoDirections == IsoDirections.E) {
                        this.addWorldItem(string, isoGridSquare, 0.42F, Rand.Next(0.34F, 0.74F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                    }

                    if (isoDirections == IsoDirections.W) {
                        this.addWorldItem(string, isoGridSquare, 0.64F, Rand.Next(0.34F, 0.74F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                    }

                    if (isoDirections == IsoDirections.N) {
                        this.addWorldItem(string, isoGridSquare, Rand.Next(0.44F, 0.64F), 0.67F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                    }

                    if (isoDirections == IsoDirections.S) {
                        this.addWorldItem(string, isoGridSquare, Rand.Next(0.44F, 0.64F), 0.42F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                    }
                }

                return;
            }
        }
    }

    private void doKitchenStuff(IsoGridSquare isoGridSquare) {
        boolean boolean0 = false;
        boolean boolean1 = false;

        for (int int0 = 0; int0 < isoGridSquare.getObjects().size(); int0++) {
            IsoObject isoObject0 = isoGridSquare.getObjects().get(int0);
            if (isoObject0.getSprite() == null || isoObject0.getSprite().getName() == null) {
                return;
            }

            if (!boolean0 && isoObject0.getSprite().getName().contains("sink") && Rand.NextBool(4)) {
                IsoDirections isoDirections0 = this.getFacing(isoObject0.getSprite());
                if (isoDirections0 != null) {
                    this.generateSinkClutter(isoDirections0, isoObject0, isoGridSquare, kitchenSinkItems);
                    boolean0 = true;
                }
            } else if (!boolean1 && isoObject0.getContainer() != null && "counter".equals(isoObject0.getContainer().getType()) && Rand.NextBool(6)) {
                boolean boolean2 = true;

                for (int int1 = 0; int1 < isoGridSquare.getObjects().size(); int1++) {
                    IsoObject isoObject1 = isoGridSquare.getObjects().get(int1);
                    if (isoObject1.getSprite() != null && isoObject1.getSprite().getName() != null && isoObject1.getSprite().getName().contains("sink")
                        || isoObject1 instanceof IsoStove
                        || isoObject1 instanceof IsoRadio) {
                        boolean2 = false;
                        break;
                    }
                }

                if (boolean2) {
                    IsoDirections isoDirections1 = this.getFacing(isoObject0.getSprite());
                    if (isoDirections1 != null) {
                        this.generateCounterClutter(isoDirections1, isoObject0, isoGridSquare, kitchenCounterItems);
                        boolean1 = true;
                    }
                }
            } else if (isoObject0 instanceof IsoStove
                && isoObject0.getContainer() != null
                && "stove".equals(isoObject0.getContainer().getType())
                && Rand.NextBool(4)) {
                IsoDirections isoDirections2 = this.getFacing(isoObject0.getSprite());
                if (isoDirections2 != null) {
                    this.generateKitchenStoveClutter(isoDirections2, isoObject0, isoGridSquare);
                }
            }
        }
    }

    private void doBathroomStuff(IsoGridSquare isoGridSquare) {
        boolean boolean0 = false;
        boolean boolean1 = false;

        for (int int0 = 0; int0 < isoGridSquare.getObjects().size(); int0++) {
            IsoObject isoObject0 = isoGridSquare.getObjects().get(int0);
            if (isoObject0.getSprite() == null || isoObject0.getSprite().getName() == null) {
                return;
            }

            if (!boolean0 && !boolean1 && isoObject0.getSprite().getName().contains("sink") && Rand.NextBool(5) && isoObject0.getSurfaceOffsetNoTable() > 0.0F) {
                IsoDirections isoDirections0 = this.getFacing(isoObject0.getSprite());
                if (isoDirections0 != null) {
                    this.generateSinkClutter(isoDirections0, isoObject0, isoGridSquare, bathroomSinkItems);
                    boolean0 = true;
                }
            } else if (!boolean0 && !boolean1 && isoObject0.getContainer() != null && "counter".equals(isoObject0.getContainer().getType()) && Rand.NextBool(5)
                )
             {
                boolean boolean2 = true;

                for (int int1 = 0; int1 < isoGridSquare.getObjects().size(); int1++) {
                    IsoObject isoObject1 = isoGridSquare.getObjects().get(int1);
                    if (isoObject1.getSprite() != null && isoObject1.getSprite().getName() != null && isoObject1.getSprite().getName().contains("sink")
                        || isoObject1 instanceof IsoStove
                        || isoObject1 instanceof IsoRadio) {
                        boolean2 = false;
                        break;
                    }
                }

                if (boolean2) {
                    IsoDirections isoDirections1 = this.getFacing(isoObject0.getSprite());
                    if (isoDirections1 != null) {
                        this.generateCounterClutter(isoDirections1, isoObject0, isoGridSquare, bathroomSinkItems);
                        boolean1 = true;
                    }
                }
            }
        }
    }

    private void generateKitchenStoveClutter(IsoDirections isoDirections, IsoObject isoObject, IsoGridSquare isoGridSquare) {
        int _int = Rand.Next(1, 3);
        String string = (String)kitchenStoveItems.get(Rand.Next(1, kitchenStoveItems.size()));
        if (isoDirections == IsoDirections.W) {
            switch (_int) {
                case 1:
                    this.addWorldItem(string, isoGridSquare, 0.5703125F, 0.8046875F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                    break;
                case 2:
                    this.addWorldItem(string, isoGridSquare, 0.5703125F, 0.2578125F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
            }
        }

        if (isoDirections == IsoDirections.E) {
            switch (_int) {
                case 1:
                    this.addWorldItem(string, isoGridSquare, 0.5F, 0.7890625F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                    break;
                case 2:
                    this.addWorldItem(string, isoGridSquare, 0.5F, 0.1875F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
            }
        }

        if (isoDirections == IsoDirections.S) {
            switch (_int) {
                case 1:
                    this.addWorldItem(string, isoGridSquare, 0.3125F, 0.53125F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                    break;
                case 2:
                    this.addWorldItem(string, isoGridSquare, 0.875F, 0.53125F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
            }
        }

        if (isoDirections == IsoDirections.N) {
            switch (_int) {
                case 1:
                    this.addWorldItem(string, isoGridSquare, 0.3203F, 0.523475F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                    break;
                case 2:
                    this.addWorldItem(string, isoGridSquare, 0.8907F, 0.523475F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
            }
        }
    }

    private void generateCounterClutter(IsoDirections isoDirections, IsoObject isoObject, IsoGridSquare isoGridSquare, HashMap<Integer, String> hashMap) {
        int int0 = Math.min(5, hashMap.size() + 1);
        int int1 = Rand.Next(1, int0);
        ArrayList arrayList0 = new ArrayList();

        for (int int2 = 0; int2 < int1; int2++) {
            int int3 = Rand.Next(1, 5);
            boolean _boolean = false;

            while (!_boolean) {
                if (!arrayList0.contains(int3)) {
                    arrayList0.add(int3);
                    _boolean = true;
                } else {
                    int3 = Rand.Next(1, 5);
                }
            }

            if (arrayList0.size() == 4) {
            }
        }

        ArrayList arrayList1 = new ArrayList();

        for (int int4 = 0; int4 < arrayList0.size(); int4++) {
            int int5 = (Integer)arrayList0.get(int4);
            int int6 = Rand.Next(1, hashMap.size() + 1);
            String string = null;

            while (string == null) {
                string = (String)hashMap.get(int6);
                if (arrayList1.contains(string)) {
                    string = null;
                    int6 = Rand.Next(1, hashMap.size() + 1);
                }
            }

            arrayList1.add(string);
            if (isoDirections == IsoDirections.S) {
                switch (int5) {
                    case 1:
                        this.addWorldItem(string, isoGridSquare, 0.138F, Rand.Next(0.2F, 0.523F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 2:
                        this.addWorldItem(string, isoGridSquare, 0.383F, Rand.Next(0.2F, 0.523F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 3:
                        this.addWorldItem(string, isoGridSquare, 0.633F, Rand.Next(0.2F, 0.523F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 4:
                        this.addWorldItem(string, isoGridSquare, 0.78F, Rand.Next(0.2F, 0.523F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                }
            }

            if (isoDirections == IsoDirections.N) {
                switch (int5) {
                    case 1:
                        isoGridSquare.AddWorldInventoryItem(string, 0.133F, Rand.Next(0.53125F, 0.9375F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 2:
                        isoGridSquare.AddWorldInventoryItem(string, 0.38F, Rand.Next(0.53125F, 0.9375F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 3:
                        isoGridSquare.AddWorldInventoryItem(string, 0.625F, Rand.Next(0.53125F, 0.9375F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 4:
                        isoGridSquare.AddWorldInventoryItem(string, 0.92F, Rand.Next(0.53125F, 0.9375F), isoObject.getSurfaceOffsetNoTable() / 96.0F);
                }
            }

            if (isoDirections == IsoDirections.E) {
                switch (int5) {
                    case 1:
                        isoGridSquare.AddWorldInventoryItem(string, Rand.Next(0.226F, 0.593F), 0.14F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 2:
                        isoGridSquare.AddWorldInventoryItem(string, Rand.Next(0.226F, 0.593F), 0.33F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 3:
                        isoGridSquare.AddWorldInventoryItem(string, Rand.Next(0.226F, 0.593F), 0.64F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 4:
                        isoGridSquare.AddWorldInventoryItem(string, Rand.Next(0.226F, 0.593F), 0.92F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                }
            }

            if (isoDirections == IsoDirections.W) {
                switch (int5) {
                    case 1:
                        isoGridSquare.AddWorldInventoryItem(string, Rand.Next(0.5859375F, 0.9F), 0.21875F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 2:
                        isoGridSquare.AddWorldInventoryItem(string, Rand.Next(0.5859375F, 0.9F), 0.421875F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 3:
                        isoGridSquare.AddWorldInventoryItem(string, Rand.Next(0.5859375F, 0.9F), 0.71F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 4:
                        isoGridSquare.AddWorldInventoryItem(string, Rand.Next(0.5859375F, 0.9F), 0.9175F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                }
            }
        }
    }

    private void generateSinkClutter(IsoDirections isoDirections, IsoObject isoObject, IsoGridSquare isoGridSquare, HashMap<Integer, String> hashMap) {
        int int0 = Math.min(5, hashMap.size() + 1);
        int int1 = Rand.Next(1, int0);
        ArrayList arrayList0 = new ArrayList();

        for (int int2 = 0; int2 < int1; int2++) {
            int int3 = Rand.Next(1, 5);
            boolean _boolean = false;

            while (!_boolean) {
                if (!arrayList0.contains(int3)) {
                    arrayList0.add(int3);
                    _boolean = true;
                } else {
                    int3 = Rand.Next(1, 5);
                }
            }

            if (arrayList0.size() == 4) {
            }
        }

        ArrayList arrayList1 = new ArrayList();

        for (int int4 = 0; int4 < arrayList0.size(); int4++) {
            int int5 = (Integer)arrayList0.get(int4);
            int int6 = Rand.Next(1, hashMap.size() + 1);
            String string = null;

            while (string == null) {
                string = (String)hashMap.get(int6);
                if (arrayList1.contains(string)) {
                    string = null;
                    int6 = Rand.Next(1, hashMap.size() + 1);
                }
            }

            arrayList1.add(string);
            if (isoDirections == IsoDirections.S) {
                switch (int5) {
                    case 1:
                        this.addWorldItem(string, isoGridSquare, 0.71875F, 0.125F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 2:
                        this.addWorldItem(string, isoGridSquare, 0.0935F, 0.21875F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 3:
                        this.addWorldItem(string, isoGridSquare, 0.1328125F, 0.589375F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 4:
                        this.addWorldItem(string, isoGridSquare, 0.7890625F, 0.589375F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                }
            }

            if (isoDirections == IsoDirections.N) {
                switch (int5) {
                    case 1:
                        this.addWorldItem(string, isoGridSquare, 0.921875F, 0.921875F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 2:
                        this.addWorldItem(string, isoGridSquare, 0.1640625F, 0.8984375F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 3:
                        this.addWorldItem(string, isoGridSquare, 0.021875F, 0.5F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 4:
                        this.addWorldItem(string, isoGridSquare, 0.8671875F, 0.5F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                }
            }

            if (isoDirections == IsoDirections.E) {
                switch (int5) {
                    case 1:
                        this.addWorldItem(string, isoGridSquare, 0.234375F, 0.859375F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 2:
                        this.addWorldItem(string, isoGridSquare, 0.59375F, 0.875F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 3:
                        this.addWorldItem(string, isoGridSquare, 0.53125F, 0.125F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 4:
                        this.addWorldItem(string, isoGridSquare, 0.210937F, 0.1328125F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                }
            }

            if (isoDirections == IsoDirections.W) {
                switch (int5) {
                    case 1:
                        this.addWorldItem(string, isoGridSquare, 0.515625F, 0.109375F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 2:
                        this.addWorldItem(string, isoGridSquare, 0.578125F, 0.890625F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 3:
                        this.addWorldItem(string, isoGridSquare, 0.8828125F, 0.8984375F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                        break;
                    case 4:
                        this.addWorldItem(string, isoGridSquare, 0.8671875F, 0.1653125F, isoObject.getSurfaceOffsetNoTable() / 96.0F);
                }
            }
        }
    }

    private IsoDirections getFacing(IsoSprite isoSprite) {
        if (isoSprite != null && isoSprite.getProperties().Is("Facing")) {
            String string = isoSprite.getProperties().Val("Facing");
            switch (string) {
                case "N":
                    return IsoDirections.N;
                case "S":
                    return IsoDirections.S;
                case "W":
                    return IsoDirections.W;
                case "E":
                    return IsoDirections.E;
            }
        }

        return null;
    }

    private void checkForTableSpawn(BuildingDef buildingDef, IsoObject isoObject) {
        if (Rand.NextBool(10)) {
            RBTableStoryBase rBTableStoryBase = RBTableStoryBase.getRandomStory(isoObject.getSquare(), isoObject);
            if (rBTableStoryBase != null) {
                rBTableStoryBase.randomizeBuilding(buildingDef);
                this.doneTable = true;
            }
        }
    }

    private IsoObject checkForTable(IsoGridSquare isoGridSquare, IsoObject isoObject0) {
        if (!this.tablesDone.contains(isoObject0) && isoGridSquare != null) {
            for (int _int = 0; _int < isoGridSquare.getObjects().size(); _int++) {
                IsoObject isoObject1 = isoGridSquare.getObjects().get(_int);
                if (!this.tablesDone.contains(isoObject1)
                    && isoObject1.getProperties().isTable()
                    && isoObject1.getProperties().getSurface() == 34
                    && isoObject1.getContainer() == null
                    && isoObject1 != isoObject0) {
                    return isoObject1;
                }
            }

            return null;
        } else {
            return null;
        }
    }

    public void doProfessionStory(BuildingDef def, String professionChoosed) {
        this.spawnItemsInContainers(def, professionChoosed, 70);
    }

    private void addRandomDeadSurvivorStory(BuildingDef buildingDef) {
        this.initRDSMap(buildingDef);
        int int0 = Rand.Next(this.totalChanceRDS);
        Iterator iterator = rdsMap.keySet().iterator();
        int int1 = 0;

        while (iterator.hasNext()) {
            RandomizedDeadSurvivorBase randomizedDeadSurvivorBase = (RandomizedDeadSurvivorBase)iterator.next();
            int1 += rdsMap.get(randomizedDeadSurvivorBase);
            if (int0 < int1) {
                randomizedDeadSurvivorBase.randomizeDeadSurvivor(buildingDef);
                if (randomizedDeadSurvivorBase.isUnique()) {
                    getUniqueRDSSpawned().add(randomizedDeadSurvivorBase.getName());
                }
                break;
            }
        }
    }

    private void initRDSMap(BuildingDef buildingDef) {
        this.totalChanceRDS = 0;
        rdsMap.clear();

        for (int _int = 0; _int < this.deadSurvivorsStory.size(); _int++) {
            RandomizedDeadSurvivorBase randomizedDeadSurvivorBase = (RandomizedDeadSurvivorBase)this.deadSurvivorsStory.get(_int);
            if (randomizedDeadSurvivorBase.isValid(buildingDef, false)
                && randomizedDeadSurvivorBase.isTimeValid(false)
                && (
                    randomizedDeadSurvivorBase.isUnique() && !getUniqueRDSSpawned().contains(randomizedDeadSurvivorBase.getName())
                        || !randomizedDeadSurvivorBase.isUnique()
                )) {
                this.totalChanceRDS = this.totalChanceRDS + ((RandomizedDeadSurvivorBase)this.deadSurvivorsStory.get(_int)).getChance();
                rdsMap.put(
                    (RandomizedDeadSurvivorBase)this.deadSurvivorsStory.get(_int), ((RandomizedDeadSurvivorBase)this.deadSurvivorsStory.get(_int)).getChance()
                );
            }
        }
    }

    public void doRandomDeadSurvivorStory(BuildingDef buildingDef, RandomizedDeadSurvivorBase DSDef) {
        DSDef.randomizeDeadSurvivor(buildingDef);
    }

    public RBBasic() {
        this.name = "RBBasic";
        this.deadSurvivorsStory.add(new RDSBleach());
        this.deadSurvivorsStory.add(new RDSGunslinger());
        this.deadSurvivorsStory.add(new RDSGunmanInBathroom());
        this.deadSurvivorsStory.add(new RDSZombieLockedBathroom());
        this.deadSurvivorsStory.add(new RDSDeadDrunk());
        this.deadSurvivorsStory.add(new RDSSpecificProfession());
        this.deadSurvivorsStory.add(new RDSZombiesEating());
        this.deadSurvivorsStory.add(new RDSBandPractice());
        this.deadSurvivorsStory.add(new RDSBathroomZed());
        this.deadSurvivorsStory.add(new RDSBedroomZed());
        this.deadSurvivorsStory.add(new RDSFootballNight());
        this.deadSurvivorsStory.add(new RDSHenDo());
        this.deadSurvivorsStory.add(new RDSStagDo());
        this.deadSurvivorsStory.add(new RDSStudentNight());
        this.deadSurvivorsStory.add(new RDSPokerNight());
        this.deadSurvivorsStory.add(new RDSSuicidePact());
        this.deadSurvivorsStory.add(new RDSPrisonEscape());
        this.deadSurvivorsStory.add(new RDSPrisonEscapeWithPolice());
        this.deadSurvivorsStory.add(new RDSSkeletonPsycho());
        this.deadSurvivorsStory.add(new RDSCorpsePsycho());
        this.deadSurvivorsStory.add(new RDSPoliceAtHouse());
        this.deadSurvivorsStory.add(new RDSHouseParty());
        this.deadSurvivorsStory.add(new RDSTinFoilHat());
        this.deadSurvivorsStory.add(new RDSHockeyPsycho());
        this.specificProfessionDistribution.add("Carpenter");
        this.specificProfessionDistribution.add("Electrician");
        this.specificProfessionDistribution.add("Farmer");
        this.specificProfessionDistribution.add("Nurse");
        this.specificProfessionRoomDistribution.put("Carpenter", "kitchen");
        this.specificProfessionRoomDistribution.put("Electrician", "kitchen");
        this.specificProfessionRoomDistribution.put("Farmer", "kitchen");
        this.specificProfessionRoomDistribution.put("Nurse", "kitchen");
        this.specificProfessionRoomDistribution.put("Nurse", "bathroom");
        this.coldFood.add("Base.Chicken");
        this.coldFood.add("Base.Steak");
        this.coldFood.add("Base.PorkChop");
        this.coldFood.add("Base.MuttonChop");
        this.coldFood.add("Base.MeatPatty");
        this.coldFood.add("Base.FishFillet");
        this.coldFood.add("Base.Salmon");
        this.plankStash.put("floors_interior_tilesandwood_01_40", "floors_interior_tilesandwood_01_56");
        this.plankStash.put("floors_interior_tilesandwood_01_41", "floors_interior_tilesandwood_01_57");
        this.plankStash.put("floors_interior_tilesandwood_01_42", "floors_interior_tilesandwood_01_58");
        this.plankStash.put("floors_interior_tilesandwood_01_43", "floors_interior_tilesandwood_01_59");
        this.plankStash.put("floors_interior_tilesandwood_01_44", "floors_interior_tilesandwood_01_60");
        this.plankStash.put("floors_interior_tilesandwood_01_45", "floors_interior_tilesandwood_01_61");
        this.plankStash.put("floors_interior_tilesandwood_01_46", "floors_interior_tilesandwood_01_62");
        this.plankStash.put("floors_interior_tilesandwood_01_47", "floors_interior_tilesandwood_01_63");
        this.plankStash.put("floors_interior_tilesandwood_01_52", "floors_interior_tilesandwood_01_68");
        kitchenSinkItems.put(1, "Soap2");
        kitchenSinkItems.put(2, "CleaningLiquid2");
        kitchenSinkItems.put(3, "Sponge");
        kitchenCounterItems.put(1, "Dogfood");
        kitchenCounterItems.put(2, "CannedCorn");
        kitchenCounterItems.put(3, "CannedPeas");
        kitchenCounterItems.put(4, "CannedPotato2");
        kitchenCounterItems.put(5, "CannedSardines");
        kitchenCounterItems.put(6, "CannedTomato2");
        kitchenCounterItems.put(7, "CannedCarrots2");
        kitchenCounterItems.put(8, "CannedChili");
        kitchenCounterItems.put(9, "CannedBolognese");
        kitchenCounterItems.put(10, "TinOpener");
        kitchenCounterItems.put(11, "WaterBottleFull");
        kitchenCounterItems.put(12, "Cereal");
        kitchenCounterItems.put(13, "CerealBowl");
        kitchenCounterItems.put(14, "Spoon");
        kitchenCounterItems.put(15, "Fork");
        kitchenCounterItems.put(16, "KitchenKnife");
        kitchenCounterItems.put(17, "ButterKnife");
        kitchenCounterItems.put(18, "BreadKnife");
        kitchenCounterItems.put(19, "DishCloth");
        kitchenCounterItems.put(20, "RollingPin");
        kitchenCounterItems.put(21, "EmptyJar");
        kitchenCounterItems.put(22, "Bowl");
        kitchenCounterItems.put(23, "MugWhite");
        kitchenCounterItems.put(24, "MugRed");
        kitchenCounterItems.put(25, "Mugl");
        kitchenCounterItems.put(26, "WaterPot");
        kitchenCounterItems.put(27, "WaterSaucepan");
        kitchenCounterItems.put(28, "PotOfSoup");
        kitchenCounterItems.put(29, "StewBowl");
        kitchenCounterItems.put(30, "SoupBowl");
        kitchenCounterItems.put(31, "WaterSaucepanPasta");
        kitchenCounterItems.put(32, "WaterSaucepanRice");
        kitchenStoveItems.put(1, "WaterSaucepanRice");
        kitchenStoveItems.put(2, "WaterSaucepanPasta");
        kitchenStoveItems.put(3, "WaterPot");
        kitchenStoveItems.put(4, "PotOfSoup");
        kitchenStoveItems.put(5, "WaterSaucepan");
        kitchenStoveItems.put(6, "PotOfStew");
        kitchenStoveItems.put(7, "PastaPot");
        kitchenStoveItems.put(8, "RicePot");
        bathroomSinkItems.put(1, "Comb");
        bathroomSinkItems.put(2, "Cologne");
        bathroomSinkItems.put(3, "Antibiotics");
        bathroomSinkItems.put(4, "Bandage");
        bathroomSinkItems.put(5, "Pills");
        bathroomSinkItems.put(6, "PillsAntiDep");
        bathroomSinkItems.put(7, "PillsBeta");
        bathroomSinkItems.put(8, "PillsSleepingTablets");
        bathroomSinkItems.put(9, "PillsVitamins");
        bathroomSinkItems.put(10, "Lipstick");
        bathroomSinkItems.put(11, "MakeupEyeshadow");
        bathroomSinkItems.put(12, "MakeupFoundation");
        bathroomSinkItems.put(13, "Perfume");
        bathroomSinkItems.put(14, "Razor");
        bathroomSinkItems.put(15, "Toothbrush");
        bathroomSinkItems.put(16, "Toothpaste");
        bathroomSinkItems.put(17, "Tweezers");
    }

    public ArrayList<RandomizedDeadSurvivorBase> getSurvivorStories() {
        return this.deadSurvivorsStory;
    }

    public ArrayList<String> getSurvivorProfession() {
        return this.specificProfessionDistribution;
    }

    public static ArrayList<String> getUniqueRDSSpawned() {
        return uniqueRDSSpawned;
    }
}
